package com.ruoyi.drawing.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.utils.BeanCopyUtils;
import com.ruoyi.drawing.api.params.FileParams;
import org.springframework.stereotype.Service;
import com.ruoyi.drawing.mapper.DtsFileMapper;
import com.ruoyi.drawing.domain.DtsFile;
import com.ruoyi.drawing.service.IDtsFileService;

import java.util.List;

/**
 * 上传文件信息Service业务层处理
 *
 * @author ZhangYu
 * @date 2024-04-30
 */
@Service
public class DtsFileServiceImpl extends ServiceImpl<DtsFileMapper, DtsFile> implements IDtsFileService {

    @Override
    public void addFileList(List<FileParams> fileParamsList, Long connectTableId, String connectTableName) {
        if (CollectionUtil.isEmpty(fileParamsList)) {
            return;
        }
        List<DtsFile> fileList = BeanCopyUtils.copyList(fileParamsList, DtsFile.class);
        for (DtsFile file : fileList) {
            file.setId(IdWorker.getId());
            file.setTableName(connectTableName);
            file.setConnectTableId(connectTableId);
        }
        super.saveBatch(fileList);
    }

}
